from google.appengine.ext import webapp
from google.appengine.ext.webapp import util

from controllers.home import HomeHandler
from controllers.available_stories import AvailableStoriesHandler
from controllers.sub_activity_hook import SubProjectActivityHookHandler
from controllers.master_activity_hook import MasterProjectActivityHookHandler
from controllers.user_home import UserHomeHandler
from controllers.add_project import AddProjectHandler
from controllers.add_subproject import AddSubprojectHandler
from controllers.project import ProjectHandler

urls = [
        (r'/', HomeHandler),
        (r'^/api/projects/([^/]*)/$', AvailableStoriesHandler),
        (r'^/api/projects/([^/]*)/activity/$', SubProjectActivityHookHandler),
        (r'^/api/projects/([^/]*)/master/$', MasterProjectActivityHookHandler),
        (r'^/secure/$', UserHomeHandler),
        (r'^/secure/addproject/$', AddProjectHandler),
        (r'^/secure/([^/]*)/', ProjectHandler),
        (r'^/secure/([^/]*)/addsubproject/$', AddSubprojectHandler)
       ]

# Google App Engine Does some optimizations if your script has a main method 
# It will invoke main() subsequent requests instead of parsing the whole file
def main(): 
    application = webapp.WSGIApplication(urls, debug = True)
    util.run_wsgi_app(application)

if __name__ == '__main__':
    main()